﻿using UnityEngine;
using System.Collections;

public class SummonHoleObj : CharacterAction{
	public GameObject[] enemyPrefabs;
	public GameObject holeObjPrefab;
	public float radius = 3.0f;
	public float angle = 0.2f;

	public override void OnActionEnter(Character character)
	{
		base.OnActionEnter(character);
		StartCoroutine("Generate");
	}

	IEnumerator Generate()
	{
		yield return StartCoroutine("GenerateHole");
		yield return StartCoroutine("GenerateEnemyTeam");
	}

	IEnumerator GenerateHole()
	{
		GameObject hole = (GameObject)Instantiate(holeObjPrefab);
		hole.transform.position = character.transform.position;

		yield return null;
	}

	IEnumerator GenerateEnemyTeam()
    {
		for(int i=0;i<enemyPrefabs.Length;i++)
		{
			GameObject enemy = (GameObject)Instantiate(enemyPrefabs[i]);
			enemy.transform.position = character.transform.position + new Vector3(radius * Mathf.Cos(angle*i),0, radius*Mathf.Sin(angle*i));
			enemy.SetActive(true);
			yield return new WaitForSeconds(4.0f);

		}
	}
	/*
	IEnumerator GenerateEnemyTeam()
	{
		EnemyFactory.instance.Create(CharacterType.ArcherType);
		yield return new WaitForSeconds(1.0f);
		EnemyFactory.instance.Create(CharacterType.AxerType);
		yield return new WaitForSeconds(1.0f);
		EnemyFactory.instance.Create(CharacterType.AxerType);
		yield return new WaitForSeconds(1.0f);
		EnemyFactory.instance.Create(CharacterType.CurerType);
		yield return new WaitForSeconds(1.0f);

		yield return null;
	}

	void GenerateEnemy(CharacterType type)
	{	

	}
	*/

}
